<template>
  <div class="app-container">
    <el-card class="card-box">
      <div class="flexDiv" style="justify-content: space-between">
        <div class="flexDiv" style="width: 300px">
          <div class="card-title">查看</div>
          <div class="card-time">
            演习时常：{{ Math.ceil(detailInfo.duration / 60) }}分钟
          </div>
        </div>
        <div>
          <el-button
            type="text"
            icon="el-icon-close"
            @click="goback"
            style="color: black"
          ></el-button>
        </div>
      </div>
      <el-card>
        <div class="flexDiv">
          <div class="form-title">基础设置</div>
        </div>
        <el-form :inline="true" :model="queryParams">
          <el-form-item label="演习名称：" style="width: 300px">
            <a style="font-weight: 400">{{ detailInfo.pracName }}</a>
          </el-form-item>
          <el-form-item label="计划时间" style="width: 300px">
            <a style="font-weight: 400">{{ detailInfo.pracPlanTime }}</a>
          </el-form-item>
          <el-form-item label="堆芯名称" style="width: 300px">
            <a style="font-weight: 400">{{ detailInfo.facNames }}</a>
          </el-form-item>
        </el-form>
      </el-card>
    </el-card>
    <el-card class="content-card">
      <div class="flexDiv">
        <div class="form-title" style="margin-bottom: 10px">脚本设置</div>
      </div>
      <div class="flexDiv" style="width: 100%">
        <el-card class="left-step">
          <div style="height: 300px; width: 240px; margin: 20px">
            <el-steps direction="vertical" :active="stepActive" :space="100">
              <el-step
                title="事件序列"
                @click.native="changeStepActive(1)"
              ></el-step>
              <el-step
                title="时间加速"
                @click.native="changeStepActive(2)"
              ></el-step>
            </el-steps>
          </div>
        </el-card>
        <el-tabs
          class="right-content"
          type="border-card"
          v-model="activeName"
          @tab-click="handleClick"
          v-if="stepActive == 1"
        >
          <el-tab-pane
            :label="item.name"
            :name="item.id.toString()"
            class="work-tab"
            v-for="item of facilityData"
            :key="item.id"
          >
            <!-- <PracTable :pracId="pracId" :facId="tabName" ref="pracChild" /> -->
            <PracTable
              :object="object"
              ref="pracChild"
              @changeStepActive="changeStepActive"
            />
          </el-tab-pane>
        </el-tabs>
        <!-- 时间加速 -->
        <TimeCard
          v-else
          :pracId="pracId"
          @changeStepActive="changeStepActive"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import { praceBase, facilityList, eventList } from "@/api/emergency/script";
import PracTable from "../Tab/pracTable";
// import PracTab from "../Tab/pracTab";
import TimeCard from "../Tab/timeCard";
// import { param } from "../../../utils";
export default {
  // name: "detail",
  data() {
    return {
      pracId: "", // 路由传参演习id
      detailInfo: "", //详情信息
      facilityData: [], // 堆芯数据
      eventData: [], // 事件列表
      activeName: "1", // tab切换
      stepActive: 1, // 进度条切换 1-事件单元  2-时间加速
      total: 0,
      tabName: 1,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      facId: 1,
      queryParams: {},
      object: {
        pracId: "",
        facId: 1,
      },
      timeData: [], // 时间加速表格数据
      //=========================
    };
  },
  components: { PracTable, TimeCard },
  mounted() {
    // 获取演习详情信息
    this.getPracticeDetail();
    this.getFacilityList();
  },
  methods: {
    getPracticeDetail() {
      // this.pracId = this.$route.query.id;
      // this.object.pracId = this.$route.query.id;
      // praceBase(this.pracId).then((res) => {
      this.$axios
        .get("/static/emergency/practice/pracBase.json")
        .then((res) => {
          console.log(res);
          this.detailInfo = res.data.data;
        });
    },
    getFacilityList() {
      // facilityList().then((res) => {
      this.$axios.get("/static/emergency/data/facList.json").then((res) => {
        this.facilityData = res.data.rows;
      });
    },
    // 切换tab时重新加载数据
    handleClick(tab, event) {
      console.log(tab.name);
      this.tabName = tab.name;
      this.object.facId = tab.name;
      console.log("tabName", this.tabName, this.$refs.pracChild);
      this.$refs.pracChild[this.tabName - 1].getEventList();
    },
    eventDetail(row) {},
    changeStepActive(param) {
      this.stepActive = param;
    },
    goback() {
      this.$router.go(-1);
    },
    //=====================
  },
};
</script>

<style scoped lang="scss">
::v-deep .el-card__body {
  padding: 5px;
}
::v-deep .el-tabs__content {
  padding: 4px 10px;
}
// title
.title {
  height: 40px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: bold;
  padding: 4px 10px 20px 10px;
  .title-name {
    width: 80px;
  }
  .title-refresh {
    width: 70px;
    color: #1890ff;
    text-align: right;
    padding-right: 15px;
  }
}
.right-title {
  height: 40px;
  font-size: 14px;
  margin-left: 40px;
}

// el-form
::v-deep .el-form {
  height: 36px;
  padding: 4px 0px 0px 10px;
  .el-form-item__label {
    font-size: 14px;
    font-weight: bold;
    color: black;
  }
}
// ::v-deep .el-input__inner {
//   width: 200px;
//   height: 28px;
//   font-size: 14px;
// }
.el-button {
  height: 28px;
  width: 64px;
  font-size: 14px;
  line-height: 5px;
}
.card-box {
  padding: 0px;
  // margin-bottom: 20px;
}
// right-left
.card-left {
  width: 40%;
  height: 300px;
  // background-color: rgb(124, 66, 66);
}

.card-title {
  padding-left: 10px;
  margin: 6px 0px;
  font-size: 16px;
  font-weight: bold;
}
.flexDiv {
  display: flex;
  // justify-content: space-between;
  .card-time {
    padding-left: 20px;
    margin: 6px 0px;
    font-size: 14px;
    line-height: 24px;
  }
}
::v-deep .el-card__body {
  width: 100%;
}
::v-deep .el-input__inner {
  // width: 200px;
  height: 28px;
  font-size: 14px;
}
.form-title {
  margin-left: 8px;
  margin-top: 10px;
  font-size: 14px;
  font-weight: bold;
}
.content-card {
  // height: 500px;
  // height: 80%;
  height: calc(100vh - 260px);
  width: 100%;
  display: flex;
  justify-content: space-between;
  .left-step {
    // width: 300px;
    height: 100%;
    width: 20%;
    // background-color: rgb(134, 110, 110);
  }
  .right-content {
    // width: 900px;
    margin-left: 2%;
    width: 78%;
    // height: 100%;
    height: calc(100vh - 320px);
  }
}
</style>
